const Constants = {
    OPEN_URL: 1001,
    GO_NET_CONFIG_OR_CONTROL: 1002,
    REQUEST_HILINK_REGISTER: 1003,
    OPEN_CONTROL_PAGE: 1004
};

const getParams = function (code) {
    return {
        messageCode: code,
        bundleName: 'com.chinasoftinc.facommon',
        abilityName: 'com.chinasoftinc.facommon.CommonAbility',
        abilityType: 1,
        syncOption: 0,
        data: code,
    };
};

const TAG = 'commonBridge'

export default {

    /**
     * 打开控制页面或hilink注册
     */
    async goNetConfigOrDevicePage() {
        let params = getParams(Constants.GO_NET_CONFIG_OR_CONTROL);
        FeatureAbility.callAbility(params);
    },

    /**
     * 打开代理注册
     */
    requireProxyRegister() {
        let params = getParams(Constants.REQUEST_HILINK_REGISTER);
        FeatureAbility.callAbility(params);
    },

    /**
     * 跳转到控制页面
     * 
     * @param withData 携带的数据, json格式
     */
    jumpControlPage(withData) {
        let params = getParams(Constants.OPEN_CONTROL_PAGE);
        params.data = withData
        FeatureAbility.callAbility(params);
    },

    /**
     * 打开url连接
     */
    async openUrl(url) {
        let params = getParams(Constants.OPEN_URL);
        params.data = {
            "url": url
        }
        FeatureAbility.callAbility(params);
    },
}